package com.demo.activiti.service;

import java.util.Arrays;
import java.util.List;

import org.activiti.engine.delegate.DelegateExecution;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.demo.activiti.DAO.CompanyDAO;
import com.demo.activiti.DAO.PersonDAO;
import com.demo.activiti.entities.Company;
import com.demo.activiti.entities.Person;

@Service
public class JoinService {
    @Autowired
    PersonDAO personDAO;

    @Autowired
    private CompanyDAO companyDAO;
    

    //加入公司操作，可从DelegateExecution获取流程中的变量
    public void joinGroup(DelegateExecution execution){
     Boolean bool = (Boolean) execution.getVariable("joinApproved");
     if(bool){
          Long personId = (Long) execution.getVariable("personId");
          Long compId = (Long) execution.getVariable("compId");
//          Company comp = companyDAO.getSession().
//          Person person = personDAO.findOne(personId);
//          person.setComp(comp);
//          personDAO.save(person);
          System.out.println("加入组织成功");
     }else{
         System.out.println("加入组织失败");
     }
    }
    //获取符合条件的审批人，演示这里写死，使用应用使用实际代码
    public List<String>  findUsers(DelegateExecution execution){
        return Arrays.asList("admin","wtr");
    }

}

